<!-- 任务单详情弹窗 -->
<template>
  <el-drawer v-model="drawerVisible" :destroy-on-close="true" size="600px" :title="`详细信息`">
    <el-space direction="vertical">
      <el-descriptions :column="2" title="库房信息" border>
        <el-descriptions-item width="400" label="库房id">{{ drawerProps.row!.warehouseId }}</el-descriptions-item>
        <el-descriptions-item width="400" label="库房等级">
          <el-tag v-if="drawerProps.row!.warehouseLevel === 0" type="danger">中心库房</el-tag>
          <el-tag v-if="drawerProps.row!.warehouseLevel === 1" type="success">分站库房</el-tag>
        </el-descriptions-item>
        <el-descriptions-item width="400" label="库房名称" :span="2">{{ drawerProps.row!.warehouseName }}</el-descriptions-item>
        <el-descriptions-item width="400" label="库房地址(省)" :span="2">{{
          drawerProps.row!.warehouseAddress!.province
        }}</el-descriptions-item>
        <el-descriptions-item width="400" label="库房地址(市)" :span="2">{{
          drawerProps.row!.warehouseAddress!.city
        }}</el-descriptions-item>
        <el-descriptions-item width="400" label="库房地址(区)" :span="2">{{
          drawerProps.row!.warehouseAddress!.zone
        }}</el-descriptions-item>
        <el-descriptions-item width="400" label="详细地址" :span="2">{{
          drawerProps.row!.warehouseAddress!.detail
        }}</el-descriptions-item>
      </el-descriptions>
    </el-space>
    <el-form
      ref="ruleFormRef"
      label-width="100px"
      label-suffix=" :"
      :rules="rules"
      :disabled="drawerProps.isView"
      :model="drawerProps.row"
      :hide-required-asterisk="drawerProps.isView"
    >
    </el-form>
    <template #footer>
      <el-button @click="drawerVisible = false">关闭</el-button>
    </template>
  </el-drawer>
</template>

<script setup lang="ts" name="DetailDrawer">
import { ref, reactive } from "vue";
import { Warehouse } from "@/api/interface";
// import { getUserInfo } from "@/api/modules/user";

const rules = reactive({});

interface DrawerProps {
  title: string;
  isView: boolean;
  row: Partial<Warehouse.ResWarehouseList>;
  courierName?: String;
  api?: (params: any) => Promise<any>;
  getTableList?: () => void;
}

const drawerVisible = ref(false);
const drawerProps = ref<DrawerProps>({
  isView: false,
  title: "",
  row: {}
});

// 接收父组件传过来的参数
const acceptParams = async (params: DrawerProps) => {
  drawerProps.value = params;
  drawerVisible.value = true;
};

defineExpose({
  acceptParams
});
</script>
